import request from '@/utils/request'
import qs from 'qs'

export function login(user) {
  return request({
    url: '/user/findUser',
    method: 'post',
    data:user
  })
}

export function getInfoAPI(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function getUserApi(id) {
  return request({
    url: `/user/${id}`,
    method: 'get'
  })
}
export function getAllUsersApi() {
  return request({
    url: `/user/findAll`,
    method: 'get'
  })
}
export function getUsersApi(pageNo, pageSize, user) {
  return request({
    url: `/user?${qs.stringify(user)}`,
    params:{},
    method: 'get'
  })
}
export function delUserApi(id) {
  return request({
    url: `/user/${id}`,
    method: 'delete'
  })
}
export function delUsersApi(users) {
  return request({
    url: `/user`,
    data:users,
    method: 'delete'
  })
}
export function updateUserApi(form) {
  return request({
    url: `/user`,
    method: 'put',
    data:form,
  })
}